package com.chinaisafe.user.vo.request;

import com.chinaisafe.base.common.vo.request.PageReqVo;
import com.chinaisafe.base.common.validated.AddGroup;
import com.chinaisafe.base.common.validated.UpdateGroup;
import jakarta.validation.constraints.NotNull;
import java.time.LocalDate;
import java.time.LocalDateTime;
import com.chinaisafe.user.entity.SysModule;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.io.Serial;
import java.io.Serializable;

/**
 * SysModuleReqVO
 * Description：系统资源模块请求值对象
 *
 * @author xuefu.shu
 * @date  2024-07-12 16:06:57
 */
@Getter
@Setter
@ToString
@Accessors(chain = true)
@Schema(name = "SysModuleReqVO", description = "系统资源模块请求值对象")
public class SysModuleReqVO extends PageReqVo implements Serializable {

    @Serial
    private static final long serialVersionUID = 1L;

    @Schema(description = "主键id")
    @NotNull(groups = UpdateGroup.class, message = "主键id不能为空" )
    private Long id;

    @Schema(description = "乐观锁版本")
    private Integer version;

    @Schema(description = "应用_id")
    private Long sysAppId;

    @Schema(description = "模块名")
    private String name;

    @Schema(description = "模块编码")
    private String code;

    @Schema(description = "是否启用")
    private Boolean enable;

    @Schema(description = "模块说明")
    private String summary;


    /**
     * 将请求值对象装换为实体
     * @return SysModule
     * @author xuefu.shu
     * @date 2024-07-12 16:06:57
     */
    public SysModule convertToEntity() {
        SysModule entity = new SysModule();
        entity.setId(this.id);
        entity.setVersion(this.version);
        // 给实体对应的字段赋值 可根据实际业务删减
        entity.setSysAppId(this.sysAppId);
        entity.setName(this.name);
        entity.setEnable(this.enable);
        return entity;
    }
}
